#!/bin/bash

echo "========================================"
echo "话单查询系统 - 安装脚本"
echo "========================================"
echo

# 检查Python版本
echo "检查Python版本..."
if ! command -v python3 &> /dev/null; then
    echo
    echo "错误：未找到Python3，请先安装Python 3.7+"
    echo "Ubuntu/Debian: sudo apt install python3 python3-pip"
    echo "CentOS/RHEL: sudo yum install python3 python3-pip"
    echo "macOS: brew install python3"
    exit 1
fi

python3 --version
echo
echo "Python版本检查通过！"
echo

# 升级pip
echo "升级pip..."
python3 -m pip install --upgrade pip

# 安装依赖
echo
echo "安装依赖包..."
python3 -m pip install -r requirements.txt
if [ $? -ne 0 ]; then
    echo
    echo "错误：依赖包安装失败"
    exit 1
fi

echo
echo "========================================"
echo "安装完成！"
echo "========================================"
echo
echo "现在可以运行 ./start.sh 启动系统"
echo "或者直接运行：python3 'import paramiko.py'"
echo 